<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../vue.js"> </script>
</head>
<body>
  <div id="app">
    {{ name }}
    <hr>
    <first-cmp></first-cmp>
  </div>

  <template id="tpl">
    <div>
      <h1>这里是模板</h1>
      <p>123123</p>
      {{ name }}
      <button @click="changeName">改名</button>
    </div>
  </template>

  <script>
   // 模板里只允许有一个根节点
    Vue.component("FirstCmp",{
       template: "#tpl", // 将组件和模版产生关联
       data() {
        return {
          name: "韩梅梅"
        }
       },
       methods: {
        changeName() {
          this.name = "李雷雷"
        }
       }
    })

    new Vue({
      el: "#app", 
      data: {     
        name: "韩梅梅"
      }
    })
  </script>
</body>
</html>